package com.briup.cms.web.controller;

import com.briup.cms.bean.Inform;
import com.briup.cms.service.IInformService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(description = "接口")
@RestController
@RequestMapping("/cms_inform")

public class InformController {
    @Autowired
    private IInformService informService;

    @ApiOperation("查询所有")
    @GetMapping("findAll")
    public Message findAll(){
        List<Inform> list = informService.findAll();
        return MessageUtil.success(list);


    }
@ApiOperation("保持或更新")
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(Inform inform){
        informService.saveOrUpdate(inform);
        return MessageUtil.success(inform);
}

@GetMapping("deleteById")
public Message deleteById(long id){
        informService.deleteById(id);
        return MessageUtil.success(id);
}
}
